package com.singer.piping.method;


import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.singer.piping.Score;
import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Properties;

public class SingerScore implements Score {

    @Override
    public void score( int Id,double scores) throws Exception {
        Properties prop = new Properties();

        prop.load(new FileInputStream("src/druid.properties"));

        DataSource data = DruidDataSourceFactory.createDataSource(prop);

        Connection connection = data.getConnection();

        String sql="update t_singer\n" +
                "set score=?\n" +
                "where id=?";
        PreparedStatement set= connection.prepareStatement(sql);

       set.setDouble(1,scores);
        set.setInt(2,Id);

        set.executeUpdate();
        set.close();
        connection.close();
    }
}
